<?php
namespace Home\Controller;
use Think\Controller;
class SetController extends CommonController {
    public function index(){

    	var_dump($_SESSION);
        $this->display();
    }
    public function face()
    {
    	$this->display();
    }
    public function upload()
    {
    	$upload = new \Think\Upload();// 实例化上传类
	    $upload->maxSize   =     3145728 ;// 设置附件上传大小
	    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
	    $upload->rootPath  =     './Uploads/'; // 设置附件上传根目录
	    $upload->savePath  =     ''; // 设置附件上传（子）目录
	    // 上传文件 
	    $info   =   $upload->upload();

	    if(!$info) {// 上传错误提示错误信息
	        echo $upload->getError();
	    }else{// 上传成功
	    	$info = current($info);
	    	$path = "Uploads/".$info['savepath'].$info['savename'];
	    	$res = M('user')->where(array('id'=>$_SESSION['id']))->save(array('face'=>$path));
	        if($res){
	        	$_SESSION['face']=$path;
	        	echo $path;
	        }else{
	        	echo 0;
	        }
	    }
    }

    public function sendemail()
    {

    	$content = <<<str
    	<div><br></div><div><tincludetail><div style="font:Verdana normal 14px;color:#000;"><div><div><table style="width: 600px; border: 1px solid #ddd; border-radius: 3px; color: #555; font-family: 'Helvetica Neue Regular',Helvetica,Arial,Tahoma,'Microsoft YaHei','San Francisco','微软雅黑','Hiragino Sans GB',STHeitiSC-Light; font-size: 12px; height: auto; margin: auto; overflow: hidden; text-align: left; word-break: break-all; word-wrap: break-word;" cellspacing="0" cellpadding="0" border="0"><tbody style="margin: 0; padding: 0;"><tr style="background-color: #393D49; height: 60px; margin: 0; padding: 0;"><td style="margin: 0; padding: 0;"><div style="color: #5EB576; margin: 0; margin-left: 30px; padding: 0;"><span style="font-size: 14px; margin: 0; padding: 0; color: #5EB576; text-decoration: none;">2017年4月份</span></div></td></tr><tr style="margin: 0; padding: 0;"><td style="margin: 0; padding: 30px;"><p style="line-height: 20px; margin: 0; margin-bottom: 10px; padding: 0;">Hi，你好<em style="font-weight: 700;"></em></p>
        <div style="font-size:14px">
        作为全球范围内应用广泛的开发语言,PHP入选全球五大最受欢迎的编程语言,是Web开发首选语言。<br><br>而广州学并思PHP第八期也在4月15开班<span style="color:red">（小班制,5.5k）</span>，由刚从企业出来的老师带班，讲的全是企业中实际用到的，课程包含：前端+PHP+MYSQL+linux+微信开发+框架设计+接口设计，详情：<span style="color:red">113664000</span>。</div><p></p><a href="http://www.daniuit.com/vip/2016/index.html" style="background-color: #009E94; color: #fff; display: inline-block; height: 32px; line-height: 32px; margin: 0 15px 0 0; padding: 0 15px; text-decoration: none;" target="_blank">详情了解</a></td></tr><tr style="background-color: #fafafa; color: #999; height: 35px; margin: 0; padding: 0; text-align: center;"><td style="margin: 0; padding: 0;">系统邮件，请勿直接回复。</td></tr></tbody></table></div></div>
</div></tincludetail></div>
str;
    	
    	xbsemail('327197843@qq.com','这个是一个测试的邮件',$content);
    }
}